// NotifySuccessNode.java
package com.woniu.component;

import com.woniu.entity.Order;
import com.woniu.mapper.OrderMapper;
import com.woniu.util.OrderContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@LiteflowComponent("notifySuccess")
public class NotifySuccessNode extends NodeComponent {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public void process() throws Exception {
        OrderContext context = this.getContextBean(OrderContext.class);
        String orderId = context.getOrderId();

        // 更新订单状态为“已审批”（1）
        Order order = new Order();
        order.setOrderId(orderId);
        order.setStatus(1);

        orderMapper.update(order);
        context.setStatus(1);
        context.setApprovalSuccess(true);

        System.out.println("🎉 订单 " + orderId + " 审批通过！");
    }
}